<?php

namespace app\index\model;
use think\Model;
class FollowModal extends Model
{
    protected $name = 'car_user_follow';
    protected $autoWriteTimestamp = true;
    protected $dateFormat = 'Y/m/d H:i:s';
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';

    public function userinfo()
    {
        return $this->hasOne('UserModel', 'id', 'follow_id')->with('photoFirst')->bind([
            'nickname' => 'nickname',
            'avatar' => 'avatar',
            'photoFirst' => 'photoFirst'
        ]);
    }

    public function gzUser()
    {
        return $this->hasOne('UserModel', 'id', 'userid')->with('photoFirst')->bind([
            'nickname' => 'nickname',
            'avatar' => 'avatar',
            'photoFirst' => 'photoFirst'
        ]);
    }

    public function work()
    {
        return $this->hasOne('PhotoList', 'releaseid', 'follow_id');
    }

    public function gzWork()
    {
        return $this->hasOne('PhotoList', 'releaseid', 'userid');
    }

    public function fans()
    {
        return $this->hasOne('FollowModal', 'follow_id', 'follow_id');
    }


    public function follows()
    {
        return $this->hasOne('FollowModal', 'userid', 'follow_id');
    }

    public function followsMy()
    {
        return $this->hasOne('FollowModal', 'userid', 'follow_id');
    }

    public function childer()
    {
        return $this->hasMany('PhotoList',  'releaseid', 'userid')->limit(4)->order(['sort'=>'desc','create_at'=>'desc']);
    }

    public function fchilder()
    {
        return $this->hasMany('PhotoList',  'releaseid', 'follow_id')->limit(4)->order(['sort'=>'desc','create_at'=>'desc']);
    }
}